package com.aioserver.socketserver.aioserver.security;

import java.nio.charset.Charset;
import net.lb.baseutil.StringUtil;
import net.lb.baseutil.encrypt.RSAUtil;
import net.lb.baseutil.test.Timewatch;
import net.lb.socketserver.transfer.server.DesServerMain;
import net.lb.socketserver.transfer.server.ServerConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;

public class AuthBaseSupport
{
    protected Logger               logger     = LogManager.getLogger();
    protected static DesServerMain serverMain = null;
    protected static Charset       charset    = Charset.forName("utf-8");
    
    @BeforeClass
    public static void before()
    {
        String publicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100c142a72e01ec900d5aa4424918eed5edda36cb42c747404dc1dac91cdbed50040d2b5b0129fedbcfee0c6de90669d5541cd6b136b7dc112d267888c7e6a6033d4dffadaa68343ecd11e5e2164ca90e20be5ac972db8f832d466ba95b1521572ccbb0e304babb7c0f1c6489eef90f44915fa5f8d7af8a3f5360f10cad19471def0203010001";
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.setPort(80);
        serverConfig.setPublicKey(StringUtil.hexStringToBytes(publicKey));
        serverMain = new DesServerMain(serverConfig);
        serverMain.start();
    }
    
    @AfterClass
    public static void after()
    {
        serverMain.stop();
    }
    public static void main(String[] args)
    {
        Timewatch timewatch = new Timewatch();
        
        String publicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100c142a72e01ec900d5aa4424918eed5edda36cb42c747404dc1dac91cdbed50040d2b5b0129fedbcfee0c6de90669d5541cd6b136b7dc112d267888c7e6a6033d4dffadaa68343ecd11e5e2164ca90e20be5ac972db8f832d466ba95b1521572ccbb0e304babb7c0f1c6489eef90f44915fa5f8d7af8a3f5360f10cad19471def0203010001";
        RSAUtil rsaUtil = new RSAUtil();
        rsaUtil.setPublicKey(StringUtil.hexStringToBytes(publicKey));
        rsaUtil.encrypt("asdassada".getBytes());
        timewatch.end();
        System.err.println(timewatch.getTotal());
    }
}
